package router

import (
	"github.com/gin-gonic/gin"
	"github.com/swaggo/gin-swagger"
	"github.com/swaggo/gin-swagger/swaggerFiles"
	"net/http"
	"sgo/common/response"
	"sgo/scontext"
)

type Router interface {
	use(sc *scontext.SgoContext, r *gin.RouterGroup)
}

func Use(sc *scontext.SgoContext, engine *gin.Engine) {
	engine.GET("/", func(context *gin.Context) {
		response.JSON(context, response.Response{
			Code: http.StatusOK,
			Msg:  "sgo server is running...",
			Data: map[string]interface{}{},
		})
	})

	// swagger接口文档
	engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	// 注册路由
	System{}.use(sc, engine.Group("/system"))
	Client{}.use(sc, engine.Group("/client"))

}
